import { createRouter, createWebHistory } from "vue-router";
import Home from '../components/home/Home.vue'
	import Tabs1 from '../components/home/page/Tabs1.vue'
	import Tabs2 from '../components/home/page/Tabs2.vue'
	import Tabs3 from '../components/home/page/Tabs3.vue'
	import Tabs4 from '../components/home/page/Tabs4.vue'
	import Tabs5 from '../components/home/page/Tabs5.vue'
	// import Login from '../components/home/page/Login.vue'
import Adm from '../components/adm/Adm.vue';
	import Category from '../components/adm/page/Category.vue'
	import Adm2 from '../components/adm/page/Adm2.vue'
	import Type from '../components/adm/page/Type.vue'
	import Adm3 from '../components/adm/page/Adm3.vue'
	import Adm4 from '../components/adm/page/Adm4.vue'
	import Adm5 from '../components/adm/page/Adm5.vue'
	import Adm6 from '../components/adm/page/Adm6.vue'
	import AdmAdd from '../components/adm/page/AdmAdd.vue'
	import BookAdd from '../components/adm/page/BookAdd.vue'
	import Hotupdate from '../components/adm/page/Hotupdate.vue'

const routes = [
  {
	path:'/',
	redirect:{
		name:'Home'
	}
  },
  {
    path: "/home",
    name: "Home",
    component: Home,
	children:[
		  {
			path:'',
			name:'Tabs1',
			component:Tabs1
		  },
		  {
			path:'tabs2',
			name:'Tabs2',
			component:Tabs2
		  },
		  {
			path:'tabs3',
			name:'Tabs3',
			component:Tabs3,
			meta : {
				role : 'P'
			},
		  },
		  {
			path:'tabs4',
			name:'Tabs4',
			component:Tabs4
		  },
		  {
			path:'tabs5',
			name:'Tabs5',
			component:Tabs5
		  }
		 //  {
			// path:'login',
			// name:'Login',
			// component:Login
		 //  }
	]
  },
  {
	  path:'/adm',
	  name: "Adm",
	  component: Adm,
	  meta : {
	  	role : 'G'
	  },
	  children:[
		  {
		  	path:'category',
		  	name: "Category",
		  	component: Category,
		  },
		  {
		  	path:'adm2',
		  	name: "Adm2",
		  	component: Adm2,
		  },
		  {
			path:'type',
			name: "Type",
			component: Type,
		  },
		  {
		  	path:'adm3',
		  	name: "Adm3",
		  	component: Adm3,
		  },
		  {
		  	path:'adm4',
		  	name: "Adm4",
		  	component: Adm4,
		  },
		  {
		  	path:'adm5',
		  	name: "Adm5",
		  	component: Adm5,
		  },
		  {
		  	path:'adm6',
		  	name: "Adm6",
		  	component: Adm6,
		  },
		  {
		  	path:'admadd',
		  	name: "AdmAdd",
		  	component: AdmAdd,
		  },
		  {
		  	path:'bookadd',
		  	name: "BookAdd",
		  	component: BookAdd,
		  },
		  {
			path:'hotupdate',
			name: "Hotupdate",
			component: Hotupdate, 
		  }
	  ]
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

// router.beforeEach( (to , from , next )=>{
// 	let role = localStorage.getItem('role');
// 	if( to.meta.role == undefined || to.meta.role == '' ){
// 		next();
// 		return;
// 	}
// 	if( to.meta.role == role ){
// 		next();
// 		return;
// 	}
// 	router.replace('/home').catch( (error)=>{
// 		console.log('地址不存在');
// 	})
// })

export default router;
